<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.text.SimpleDateFormat,java.text.DateFormat,java.util.Date"%>
<%@ include file="/WEB-INF/common/taglib.jsp" %>
<%
	Date now = new Date();
	DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	String nowStr = df.format(now);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<link rel="stylesheet" href="${ctx}/static/css/Master.css"/>
	<link rel="stylesheet" href="${ctx}/static/css/lq.datetimepick.css"/>
	<script type="text/javascript" src="${ctx}/static/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/simpletooltip.min.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/jsScroller.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/selectUi.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/lq.datetimepick.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/orgCommon.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/orgAreat.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/jquery.uploadify.v2.0.3.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/swfobject.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/jquery.form.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/jquery.validate.min.js"></script>
	<link href="${ctx}/static/css/validation.css" type="text/css" rel="stylesheet"/>
	<script type="text/javascript" src="${ctx}/static/js/messages_cn.js"></script>
	<script src="${ctx}/static/plugins/My97DatePicker/WdatePicker.js"></script>
	<script src="${ctx}/static/js/layer.js"></script>
	<style type="text/css">
		#section_heigth{ height:100%; overflow:auto; border-top:1px solid #717171; background:#fff;}
		.fileline { position:relative; width:312px; height:30px; padding-bottom:10px; text-align:left}
		.fileline2{ width:160px;}
		.fileline .file { position:absolute; left:0; width:100%; top:0; height:28px; filter:alpha(opacity=0); opacity:0; cursor: pointer; padding:0 !important }
		.wrapper input{
		  height: 30px !important
		}
		.div-error{padding-left: 1px;padding-bottom: 2px;font-weight: bold;color: #EA5200;}
	</style>
	
	<script type="text/javascript">
		var filelist=[];//新增的图片集合
		function save(auditStatus)
		{
			if(!isNone())
			{
				return;
			}
			
			var data = $("#orgFrom").serializeJson();
			if(data.auditStatus == 2)
			{
				data.copyOrgId = data.orgId;
				data.auditStatus = auditStatus;
			}else{
				data.auditStatus = auditStatus;
			}
			data.filelist = JSON.stringify(filelist);
			$.ajax({
				url:"${ctx}/organization/update.do",    
			    data:data,    
			    type:"POST",    
			    cache:false,    
			    dataType:"json",
			    async:true, //默认为true 异步 
			    success:function(data) {
			    	top.layer.alert("操作成功",function(){
			    		window.location.href = "${ctx}/organization/organizationlist.do";
			    	});
			    },    
			    error : function(XMLHttpRequest, textStatus, errorThrown) {
			    	    
		  		}   
			});
		}
		
	$(document).ready(function()
	{
		$("#uploadify1").uploadify(uploader('${ctx }/file/1/uploadFile.do','imgDiv1'));
	    $("#uploadify2").uploadify(uploader('${ctx }/file/2/uploadFile.do','imgDiv2'));
	    $("#uploadify3").uploadify(uploader('${ctx }/file/3/uploadFile.do','imgDiv3'));
	    $("#uploadify4").uploadify(uploader('${ctx }/file/4/uploadFile.do','imgDiv4'));
	    $("#uploadify5").uploadify(uploader('${ctx }/file/5/uploadFile.do','imgDiv5'));
	    $("#uploadify6").uploadify(uploader('${ctx }/file/6/uploadFile.do','imgDiv6'));
	});
	
	function uploader(url,imgDiv)
	{
		var t = {
		        'uploader': '${ctx}/static/images/uploadify.swf',
		        'script': url,
		        'cancelImg': '${ctx}/static/images/cancel.png',
		        'queueID' : 'fileQueue', // 文件队列的ID，该ID与存放文件队列的div的ID一致
				'queueSizeLimit' : 1, // 当允许多文件生成时，设置选择文件的个数，【默认值：999】
				'fileDesc' : 'jpg、gif、jpeg、png文件', // 用来设置选择文件对话框中的提示文本'jpg、gif、jpeg、png文件'
				'fileExt' : '*.jpg;*.gif;*.png;*.jpeg', // 设置可以选择的文件的类型'*.jpg;*.gif;*.png;*.jpeg'
				'auto' : true, // 设置为true当选择文件后就直接上传了，为false需要点击上传按钮才上传
				'multi' : false, // 设置为true时可以上传多个文件
				'width' : 140, // 宽度
				'simUploadLimit' : 1, // 允许同时上传的个数 【默认值：1】
				'sizeLimit' : 2048000, // 上传文件的大小限制 【单位byte】
				'buttonText' : '上传图片', // 浏览按钮的文本，默认值：BROWSE
				'displayData' : 'percentage',// 上传队列显示的数据类型【percentage：百分比，speed：上传速度】
				'onComplete' : function(evt, queueID, fileObj, response, data) {
					var newFile = JSON.parse(response)[0];
					var length = filelist.push(newFile);// 将一个或多个新元素添加到数组结尾，并返回数组新长度
					$("#"+imgDiv).append('<div class="gg_img"><code url="'+newFile.filSerPath+'" onclick="removeImg(this);"><img  src="${fUrl }'+newFile.filSerPath+'" alt="" width="136px" height="80px"/></code></div>');
				},
				'onError' : function(event, queueID, fileObj, errorObj) {
					if (errorObj.type === "File Size") {
						//alert("上传文件大小限制为" + parseInt(errorObj.info/1024) + "KB");
						top.layer.msg("上传文件大小限制为" + parseInt(errorObj.info/1024) + "KB", 2,{type: 8}, function(){});
						$("#headImg").uploadifyClearQueue();
					}
				}
			};
		return t;
	}
	
	function removeImg(code){
		//删除新增的文件
		/**
		$.ajax({    
		    url:"${ctx }/file/deleteFile.do",    
		    data:{"path":$(code).attr("url"),"fileId":$(code).attr("id")},    
		    type:"post",    
		    cache:false,    
		    dataType:"json",
		    async:true, //默认为true 异步    
		    success:function(data) {    
		     },    
		     error : function() {    
		     }    
		});
		*/
		if(filelist.length > 0){
			for ( var i = 0; i < filelist.length; i++) {
				if(filelist[i].filSerPath == $(code).attr("url")){
					var oldData = filelist.splice(i,1);
				}
			}
		}
		$(code).parent().remove();
	}
	</script>
	
	<style type="text/css">
		.selectul_w1
		{
			background: #fff;
			border: 1px solid #dfdfdf;
			text-align: center;
			position: relative;
			height: 30px;
		}
	</style>
	
  </head>
  
  <body>
	<div class="wrapper">
	<form id="orgFrom" >
		<input type="hidden" id="orgId" name="orgId" value="${org.orgId }"/>
		<input type="hidden" id="contract.contractId" name="contract.contractId" value="${org.contract.contractId }"/>
		<input type="hidden" id="orgType" name="orgType" value="${org.orgType }" />
		<input type="hidden" id="normal" name="normal" value="${org.normal }" />
		<input type="hidden" id="status" name="status" value="${org.status }" />
		<input type="hidden" id="contract.status" name="contract.status" value="${org.contract.status }" />
		<input type="hidden" id="insertBy" name="insertBy" value="${org.insertBy }" />
		<input type="hidden" id="lastUpdateBy" name="lastUpdateBy" value="1" />
		<input type="hidden" id="orgPId" name="orgPId" value="${org.orgPId }" />
		<input type="hidden" id="orgPIds" name="orgPIds" value="${org.orgPIds }" />
		<input type="hidden" id="auditStatus" name="auditStatus" value="${org.auditStatus }" />
		<section>
			<section id="section_heigth" >
				<section class="boxRight">
					<div class="OrgTit">新增运营商</div>
					<div class="context">
						<div class="add_firstmenu">
							<dl>
								<dt>
									<strong class="org">基本信息</strong>
								</dt>
								<dd>
								</dd>
							</dl>
							<dl>
								<dt>
									<span class="im">*</span>平台名称
								</dt>
								<dd>
									<input id="orgName" name="orgName" type="text" class="required w1" value="${org.orgName }"/>
								</dd>
							</dl>
							<dl>
								<dt>
									<span class="im">*</span>公司注册名称
								</dt>
								<dd>
									<input id="comRegName" name="comRegName" type="text" class="required w1" value="${org.comRegName }"/>
								</dd>
							</dl>
							<dl>
								<dt>
									<span class="im">*</span>所在地
								</dt>
								<dd>
									<select id="province" name="provinceId" class="selectul selectul_w1 province required " dir="${org.provinceId }">
										<option value="0" >选择省</option>
									</select>
									<select id="city" name="cityId" class="selectul selectul_w1 city required " dir="${org.cityId }">
										<option value="0" >选择市</option>
									</select>
									<select id="area" name="areaId" class="selectul selectul_w1 area required " dir="${org.areaId }">
										<option value="0">选择区</option>
									</select>
								</dd>
							</dl>
							<dl>
								<dt>
									<span class="im">*</span>详细地址
								</dt>
								<dd>
									<input id="address" name="address" type="text" class="required w3" value="${org.address }"/>
								</dd>
							</dl>
							<dl>
								<dt>
									<span class="im">*</span>法人姓名
								</dt>
								<dd>
									<input id="corpName" name="corpName" type="text" class="required w1" value="${org.corpName }"/>
								</dd>
							</dl>
							<dl class="two">
								<dt>
									<span class="im">*</span>法人身份证号码
								</dt>
								<dd>
									<input id="corpIdCardNumber" name="corpIdCardNumber" type="text" class="required w1" value="${org.corpIdCardNumber }" maxlength="18"/>
								</dd>
								<dt>
									<span class="im">*</span>法人身份证到期时间
								</dt>
								<dd>
									<input id="corpIdCareEndDate" name="corpIdCareEndDate" type="text" class="required w1 Wdate" placeholder="法人身份证到期时间" value="${org.corpIdCareEndDate }" onclick="WdatePicker()"/>
								</dd>
							</dl>
							<dl class="two">
								<dt>
									<span class="im">*</span>营业执照号码
								</dt>
								<dd>
									<input id="businessLicenseNumber" name="businessLicenseNumber" type="text" class="required w1" value="${org.businessLicenseNumber }" maxlength="18"/>
								</dd>
								<dt>
									<span class="im">*</span>营业执照到期时间
								</dt>
								<dd>
									<input id="businessLicenseEndDate" name="businessLicenseEndDate" type="text" class="required w1 Wdate" placeholder="营业执照到期时间" value="${org.businessLicenseEndDate }" onclick="WdatePicker()"/>
								</dd>
							</dl>
							<dl class="two">
								<dt>
									<span class="im">*</span>组织代码证号码
								</dt>
								<dd>
									<input id="orgNumber" name="orgNumber" type="text" class="required w1" value="${org.orgNumber }" maxlength="18"/>
								</dd>
								<dt>
									<span class="im">*</span>机构代码到期时间
								</dt>
								<dd>
									<input id="orgEndDate" name="orgEndDate" type="text" class="required w1 Wdate" placeholder="机构代码到期时间" value="${org.orgEndDate }" onclick="WdatePicker()"/>
								</dd>
							</dl>
							<dl class="two">
								<dt>
									<span class="im">*</span>税务登记证号码
								</dt>
								<dd>
									<input id="taxRegCertifNumber" name="taxRegCertifNumber" type="text" class="required w1" value="${org.taxRegCertifNumber }" maxlength="18"/>
								</dd>
								<dt>
									<span class="im">*</span>税务登记证到期时间
								</dt>
								<dd>
									<input id="taxRegCertifEndDate" name="taxRegCertifEndDate" type="text" class="required w1 Wdate" placeholder="税务登记证到期时间" value="${org.taxRegCertifEndDate }" onclick="WdatePicker()"/>
								</dd>
							</dl>
							<dl>
								<dt>
									服务热线
								</dt>
								<dd>
									<input id="serviceHotline" name="serviceHotline" type="text" class="required w1" value="${org.serviceHotline }"/>
								</dd>
							</dl>
							<dl>
								<dt>
									<strong class="org">合同信息</strong>
								</dt>
								<dd></dd>
							</dl>
							<dl class="two">
								<dt>
									<span class="im">*</span>合同编号
								</dt>
								<dd>
									<input id="contractNumber" name="contract.contractNumber" type="text" class="required w1" value="${org.contract.contractNumber }"/>
								</dd>
								<dt>
									<span class="im">*</span>合同签署日期
								</dt>
								<dd>
									<input id="contractSignDate" name="contract.contractSignDate" type="text" class="required w1 Wdate" value="${org.contract.contractSignDate }" onclick="WdatePicker()"/>
								</dd>
							</dl>
							<dl class="two">
								<dt>
									<span class="im">*</span>合同开始日期
								</dt>
								<dd>
									<input id="contractSignBeginDate" name="contract.contractSignBeginDate" type="text" class="required w1 Wdate" value="${org.contract.contractSignBeginDate }" onclick="WdatePicker()"/>
								</dd>
								<dt>
									<span class="im">*</span>合同到期日期
								</dt>
								<dd>
									<input id="contractSignEndDate" name="contract.contractSignEndDate" type="text" class="required w1 Wdate" value="${org.contract.contractSignEndDate }" onclick="WdatePicker()"/>
								</dd>
							</dl>
							<dl class="two">
								<dt>
									广告分润
								</dt>
								<dd>
									<input id="advPercent" name="contract.advPercent" type="text" class="w1" value="${org.contract.advPercent }" />%
								</dd>
								<dt>
									交易分润
								</dt>
								<dd>
									<input id="dealPercent" name="contract.dealPercent" type="text" class="w1" value="${org.contract.dealPercent }"/>%
								</dd>
							</dl>
							<dl>
								<dt>
									<strong class="org">图片资料</strong>
								</dt>
								<dd></dd>
							</dl>
							<dl class="two sf">
								<dt><span class="im">*</span>法人身份证</dt>
								<dd>
									<div class="ddpic required" id="imgDiv1">
									<c:forEach var="dd" items="${org.fileLists }">
										<c:if test="${dd.filType == 1 }">
										<div class="gg_img">
											<code url="${dd.filSerPath}" id="${dd.filId }" onclick="removeImg(this);">
												<img src="${fUrl }${dd.filSerPath}" alt="" width="136px" height="80px" />
											</code>
										</div>
										</c:if>
									</c:forEach>
									</div>
									<div class="ddbtn prlink"><input type="file" name="uploadify1" id="uploadify1" /></div>
								</dd>
								<dt><span class="im">*</span>营业执照</dt>
								<dd>
									<div class="ddpic required" id="imgDiv2">
									<c:forEach var="dd" items="${org.fileLists }">
										<c:if test="${dd.filType == 2 }">
										<div class="gg_img">
											<code url="${dd.filSerPath}" id="${dd.filId }" onclick="removeImg(this);">
												<img src="${fUrl }${dd.filSerPath}" alt="" width="136px" height="80px" />
											</code>
										</div>
										</c:if>
									</c:forEach>
									</div>
									<div class="ddbtn prlink"><input type="file" name="uploadify2" id="uploadify2" /></div>
								</dd>
							</dl>
							<dl class="two sf">
								<dt><span class="im">*</span>税务登记证</dt>
								<dd>
									<div class="ddpic required" id="imgDiv3">
									<c:forEach var="dd" items="${org.fileLists }">
									<c:if test="${dd.filType == 3 }">
									<div class="gg_img">
										<code url="${dd.filSerPath}" id="${dd.filId }" onclick="removeImg(this);">
											<img src="${fUrl }${dd.filSerPath}" alt="" width="136px" height="80px" />
										</code>
									</div>
									</c:if>
									</c:forEach>
									</div>
									<div class="ddbtn prlink"><input type="file" name="uploadify3" id="uploadify3" /></div>
								</dd>
								<dt><span class="im">*</span>机构代码证</dt>
								<dd>
									<div class="ddpic required" id="imgDiv4">
									<c:forEach var="dd" items="${org.fileLists }">
										<c:if test="${dd.filType == 4 }">
										<div class="gg_img">
											<code url="${dd.filSerPath}" id="${dd.filId }" onclick="removeImg(this);">
												<img src="${fUrl }${dd.filSerPath}" alt="" width="136px" height="80px" />
											</code>
										</div>
										</c:if>
									</c:forEach>
									</div>
									<div class="ddbtn prlink"><input type="file" name="uploadify4" id="uploadify4" /></div>
								</dd>
							</dl>
							
							<dl class="two sf">
								<dt><span class="im">*</span>协议资料</dt>
								<dd>
									<div class="ddpic required" id="imgDiv5">
									<c:forEach var="dd" items="${org.fileLists }">
										<c:if test="${dd.filType == 5 }">
										<div class="gg_img">
											<code url="${dd.filSerPath}" id="${dd.filId }" onclick="removeImg(this);">
												<img src="${fUrl }${dd.filSerPath}" alt="" width="136px" height="80px" />
											</code>
										</div>
										</c:if>
									</c:forEach>
									</div>
									<div class="ddbtn prlink"><input type="file" name="uploadify5" id="uploadify5" /></div>
								</dd>
							</dl>
							
							<dl class="two sf">
								<dt>LOGO</dt>
								<dd>
									<div class="ddpic" id="imgDiv6">
									<c:forEach var="dd" items="${org.fileLists }">
										<c:if test="${dd.filType == 6 }">
										<div class="gg_img">
											<code url="${dd.filSerPath}" id="${dd.filId }" onclick="removeImg(this,this.id);">
												<img src="${fUrl }${dd.filSerPath}" alt="" width="136px" height="80px" />
											</code>
										</div>
										</c:if>
									</c:forEach>
									</div>
									<div class="ddbtn prlink"><input type="file" name="uploadify6" id="uploadify6" /></div>
								</dd>
							</dl>
							<dl>
								<dt>
									<strong class="org">联系人资料</strong>
								</dt>
								<dd></dd>
							</dl>
							<dl>
								<dt>
									联系人
								</dt>
								<dd><input id="contactName" name="contactName" type="text" class="w1" value="${org.contactName }"/></dd>
							</dl>
							<dl>
								<dt>
									联系人手机号
								</dt>
								<dd><input id="contactNumber" name="contactNumber" maxlength="11" type="text" class="w1" value="${org.contactNumber }"/></dd>
							</dl>
							<div class="combtn"><a href="javascript:save(0);">保存</a><a href="javascript:save(1);">提交</a><a href="javascript:void(0);"onclick="history.go(-1)">返回</a></div>
						</div>
					</div>
			</section>
			</section>
		</section>
		</form>
	</div>
  </body>
</html>
